<!doctype html>
<html lang="en">
<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8"%>
<head>
    <meta charset="UTF-8">
    	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>找回密码</title>
    <meta name="keywords" content="易收债管家_收债公司_催收公司_要债公司_商账催收_贷款催收_清债公司_催收律师_专业债务催收公司">
	<meta name="Description" content="易收债管家是全国最大的不良资产催收和处置服务平台，主要提供个人债款催收、企业商账催收、贷款催收等不良资产催收服务，处置方可提供诉讼催收、非诉催收、资产收购等服务。">
    <link rel="shortcut icon" href="/assets/img/ico.png" />
    <link rel="stylesheet" href="/assets/css/ui_common.css"/>
	<link rel="stylesheet" type="text/css" href="/assets/css/repwd.css">
    <link rel="stylesheet" href="/assets/css/private_finance.css"/>
    <!–[if lte IE 8]>
    <script src="/assets/js/html5.js"></script>
    <script src="/assets/js/respond.min.js"></script>
    <![endif]–>
</head>
<body>
	<%@include file="/inc/header.jsp" %>
  <div class="repwd">
        <div class="repwdcon">
            <h3 class="repwdtit">找回密码</h3>
            <div class="step1">
                <div class="repwd_step1"></div>
    			<div class="int">
                    <span class="intspan">用户名</span>
                    <input type="text" id="account">
                    <span class="ts" id="ts_account">提示提示……</span>
                </div>
                <div class="int">
                    <span class="intspan">验证码</span>
                    <input type="text" class="intspe" id="codeNum">                    
                    <img class="code" src="randCheckCode.jpg" id="codeImg" alt="看不清刷新" onclick="refreshRankCode()"></img>
                    <span class="ts" id="ts_codeImg">提示提示……</span>
                </div>
                <p  class="reg1next">
                <a href="javascript:;" class="step1btn">下一步</a>
                </p>
            </div>
            <div class="step2">
                <div class="repwd_step2"></div>
                <p class="step2p">短信验证码已发送，请注意查收</p>
                <div class="int">
                    <span class="intspan">验证码</span>
                    <input type="text" id="pcode">
                    <span class="code1"  id="sendCode"><span id="sendCodeSecond">59s</span></span>
                    <span class="ts" id="ts_pcode">提示提示……</span>
                </div>
                <p class="step2pts">如果没有收到短信，您可在<span>60s</span>后获取语音验证码</p>
                <p  class="reg1next">
                <a href="javascript:;" class="step2btn">下一步</a>
                <p class="zhao">如您无法使用上述方法找回，请联系客服400-676-888或重新注册</p>
            </div>
            <div class="step3">
                <div class="repwd_step3"></div>
                <div class="int">
                    <span class="intspan">新登录密码</span>
                    <input type="password" id="pwd">
                    <span class="ts"  id="ts_pwd">提示提示……</span>
                </div>
                <div class="int">
                    <span class="intspan">确认新登录密码</span>
                    <input type="password" id="rePwd">
                    <span class="ts" id="ts_rePwd">提示提示……</span>
                </div>
                <p  class="reg1next">
                <a href="javascript:;" class="step3btn">确认</a>
                </p>
            </div>
            <div class="step4">
                <div class="repwd_step4"></div>
                <div class="step4con">
                    <p class="step4con1">设置成功，请牢记新的登录密码</p>
                    <p class="step4con2"><span id="jumpTo">5</span>自动跳转至<a href="login.html">登录页</a></p>
                </div>
            </div>
        </div>
    </div>
    <input type="hidden" value="" id="userPhoneNumber">
	
	
  

     <%@include file="/inc/footer.jsp" %>

<script src="/assets/js/jquery2.min.js"></script>
 <script>
    $(function(){
    	$('.step1btn').click(function(){  
    		var account = $('#account').val();
    		var codeNum = $('#codeNum').val();
    		var result=true;
    	     if(account==''){
    			$('#ts_account').html('用户名不得为空');
    			$('#ts_account').show();
    			result = false;
    		}else{
    			//验证用户是否存在 
    			$.ajax({
                    type: "POST",
                    url: '/index/',
                    data:{account:account},
                    dataType: "json",
                    async:false,
                    success: function(data){
                    	if(data.result=='FAIL'){
        					$('#ts_account').html('用户名不存在');
        	    			$('#ts_account').show();
    		    			result = false;
        				}else{
        					$('#ts_account').hide();
        				}
                    }
                });   
    		}
			if(codeNum==''){
				$('#ts_codeImg').html('请输入验证码');
    			$('#ts_codeImg').show();
    			result = false;
    		}else{
    			$.ajax({
                    type: "POST",
                    url: '/index/',
                    data:{rankCode:codeNum},
                    dataType: "json",
                    async:false,
                    success: function(data){
                    	if(data.result=="SUCCESS"){
                    		$('#ts_codeImg').hide();
    	    			}else{
    	    				$('#ts_codeImg').html('验证码错误');
    	        			$('#ts_codeImg').show();
    	    				result = false;
    	    			}
                    }
                });	    			
    		}
			if(result==true){				
				$.ajax({
                    type: "POST",
                    url: '/index/',
                    dataType: "json",
                    async:false,
                    success: function(data){
                    	if(data.result=='FAIL'){
    						alert("发送验证码失败！");
    						return;
    					}else{
    						$('#userPhoneNumber').val(data.operateObject);
    					}
                    }
                });  
				$('#ts_codeImg').hide();
				$('#ts_account').hide();
				$('.step1').css("display","none");
		        $('.step2').css("display","block");	        
		        countDownTwo(59);        
			}    		
           
        });
        $('.step2btn').click(function(){
        	//用户输入的验证码
        	var result = true;
        	var codeNum = $('#pcode').val();
        	if(codeNum==''){
        		$('#ts_pcode').html('输入手机验证码。');
        		$('#ts_pcode').show();
        		result = false;
        	}else{
        		$.ajax({
                    type: "POST",
                    url: '/index/',
                    data:{phoneNumber:$('#userPhoneNumber').val(),codeNum:codeNum},
                    dataType: "json",
                    async:false,
                    success: function(data){
                    	if(data.result=='FAIL'){
        					$('#ts_pcode').html('验证码输入错误。');
        					$('#ts_pcode').show();
        					result = false;
        				}else{
        					$('#ts_pcode').hide();
        				}
                    }
                });        		
        		
        	}
        	if(result==true){        		
        		$('.step2').css("display","none");
                $('.step3').css("display","block");
        	}            
        });
        $('.step3btn').click(function(){
        	var result = true;
        	var pwd =$('#pwd').val();
        	var ckPwd = checkPwd();
        	var ckRepwd = checkRePwd();
        	if(ckPwd==true && ckRepwd==true){
        	$.ajax({
                    type: "POST",
                    url: '/index/updateRePwd',
                    data:{pwd:pwd},
                    dataType: "json",
                    async:false,
                    success: function(data){
                    	if(data.result=='FAIL'){
        					alert("修改失败！");
        					result = false;
        				}
                    }
                }); 
        		
        		if(result==true){
        			$('.step3').css("display","none");
                    $('.step4').css("display","block");   
                    countDown(5);
        		}
        		
        		
        	}
        	
        	
            
        });     
        $('.ts').hide();
        	$('#pwd').blur(function(){
        		checkPwd();
        	});
        	$('#rePwd').blur(function(){
        		checkRePwd();
        		checkPwd();
        	});
    });  
    function refreshRankCode(){
        document.getElementById("codeImg").src = document  
        .getElementById("codeImg").src  
        + "?nocache=" + new Date().getTime(); 
    }
    //发送验证码
    function getCodeNum(){      
    	$('#sendCode').unbind("click"); //移除click
  		  $.post('/index/','phoneNumber='+$('#userPhoneNumber').val(),function(data){
  			  if(data.result=="SUCCESS"){
  		       	  countDownTwo(59);    
  			  }else{
  				  alert("验证码发送失败。");
  			  }
  		  }); 	  
    }
    
    
  //验证密码
    function checkPwd(){
    	checkRePwd();
    	var pwd=$('#pwd').val();
    	var result = false;
    	var alertInfo="";
    	if(pwd==''){
    		alertInfo="密码不得为空。";
    	}else{
    		var reg = new RegExp("^[\@A-Za-z0-9\!#$\%\^\&\*\.\~]{6,22}$");
    		var regPwd = reg.test(pwd);
    		if(regPwd){
    			result = true;
    		}else{
    			alertInfo="密码长度为6-22位。";
    		}
    	}
    	if(result==true){
    		$('#ts_pwd').hide();
    	}else{
    		$('#ts_pwd').html(alertInfo);
    		$('#ts_pwd').show();
    	}
    	return result;    	
    }
  //验证重复密码
    function checkRePwd(){
    	var pwd=$('#pwd').val();
    	var rePwd = $("#rePwd").val();
    	var result = false;
    	var alertInfo="";
    	if(rePwd==''){
    		alertInfo="请再次输入密码。";
    	}else{
    		
    		if(rePwd==pwd){
    			result = true;
    		}else{
    			alertInfo="密码不一致。";
    		}
    	}
    	if(result==true){
    		$('#ts_rePwd').hide();
    	}else{
    		$('#ts_rePwd').html(alertInfo);
    		$('#ts_rePwd').show();
    	}
    	return result;    	
    }   
  	//自动跳转登录页面
    function countDown(secs){    
    	 //alert(surl);    
    	 var jumpTo = document.getElementById('jumpTo');
    	 jumpTo.innerHTML=secs+"S"; 
    	 if(--secs>0){    
    	     setTimeout("countDown("+secs+")",1000);    
    	 }   
    	 else{      
    	     location.href="/index/login";    
    	 }    
    }
  	//可以发送验证码
    function countDownTwo(secs){  
  	 
   	 var sendTo = document.getElementById('sendCodeSecond');
   		sendTo.innerHTML=secs+"s后重新发送"; 
   	 if(--secs>0){    
   	     setTimeout("countDownTwo("+secs+")",1000);    
   	 }else{      
   	     //  
   	     $('#sendCodeSecond').html("重新发送验证码");
   	     $("#sendCode").click(function(){
   	    	getCodeNum();
   	     });
   	 }    
   }
    </script>
</body>
</html>